package com.yedean.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yedean.mall.entity.UmsMember;
import com.yedean.mall.mapper.UmsMemberMapper;
import com.yedean.mall.service.IUmsMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 会员表 服务实现类
 * </p>
 *
 * @author yedean
 * @since 2022-08-03
 */
@Service
public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember> implements IUmsMemberService {
    


    @Override
    public boolean memberExist(String username) {
        LambdaQueryWrapper<UmsMember> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UmsMember::getUsername, username);
        return baseMapper.selectOne(wrapper) != null;
    }

    @Override
    public boolean memberCheck(String username, String password) {

        LambdaQueryWrapper<UmsMember> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UmsMember::getUsername, username);
        UmsMember umsMember = baseMapper.selectOne(wrapper);
        return umsMember.getPassword().equals(password);
    }

    @Override
    public UmsMember getMember(String username) {

        LambdaQueryWrapper<UmsMember> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UmsMember::getUsername, username);
        return baseMapper.selectOne(wrapper);
    }
}
